diff options
author | João Augusto Costa Branco Marado Torres <torres.dev@disroot.org> | 2025-07-27 20:09:43 -0300 |
---|---|---|
committer | João Augusto Costa Branco Marado Torres <torres.dev@disroot.org> | 2025-07-27 20:09:43 -0300 |
commit | b40682ace35b590c909e60d0c8c2556496370a51 (patch) | |
tree | c16555866c500e0131ba4a077e9d110ae2646e23 /src/pages/blog/keywords/[keyword].astro | |
parent | 4e2b619fe93ac332c8e238ca5dc03d744d3562bd (diff) |
feat: style keywords page
Signed-off-by: João Augusto Costa Branco Marado Torres <torres.dev@disroot.org>
Diffstat (limited to 'src/pages/blog/keywords/[keyword].astro')
-rw-r--r-- | src/pages/blog/keywords/[keyword].astro | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/pages/blog/keywords/[keyword].astro b/src/pages/blog/keywords/[keyword].astro new file mode 100644 index 0000000..8f0494b --- /dev/null +++ b/src/pages/blog/keywords/[keyword].astro @@ -0,0 +1,64 @@ +--- +import { type CollectionEntry, getCollection } from "astro:content"; +import Base from "@layouts/Base.astro"; +import BlogCard from "@components/BlogCard.astro"; +import SimplePostList from "@components/templates/SimplePostList.astro"; + +type Props = { posts: CollectionEntry<"blog">[] }; + +export async function getStaticPaths() { + const posts = await getCollection("blog"); + const keywords = [ + ...new Set( + await getCollection("blog").then((x) => + x.flatMap((x) => x.data.keywords) + ), + ).values(), + ]; + return keywords.map((k) => ({ + params: { keyword: k }, + props: { + posts: posts.filter((post) => + post.data.keywords.some((i) => i.localeCompare(k) === 0) + ), + }, + })); +} + +const title = `Blogue &ndash ${Astro.params.keyword}`; +const description = `Últimas postagens da categoria ${Astro.params.keyword}.`; + +const posts = Astro.props.posts.sort((a, b) => + new Date(b.data.dateCreated).valueOf() - + new Date(a.data.dateCreated).valueOf() +); +--- + +<Base {title} {description}> + <main + itemprop="mainContentOfPage" + itemscope + itemtype="https://schema.org/WebPageElement" + > + <section + id="posts" + itemprop="citation" + itemscope + itemtype="http://schema.org/Blog" + > + <h2 itemprop="name description" set:html={title} /> + <SimplePostList + {posts} + dateOptions={{ + weekday: "long", + year: "numeric", + month: "long", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + timeZoneName: "long", + }} + /> + </section> + </main> +</Base> |